﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using HK2009.Common;
using HK2009.BusinessFacade;
using HK2009.BusinessFacadeHandler;
using HK2009.EntityQuery;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using System.Threading;

public partial class SystemManage_CompanyManage : System.Web.UI.Page
{
    ISystemHandler sysManage = new SystemHandler();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            dataBind();    
        }
    }

    private void dataBind()
    {
        SystemConfigQuery linkManconfig = sysManage.GetConfig("CompanyLinkMan");
        txtCNName.Text = linkManconfig.ConfigValue;

        SystemConfigQuery telQuery = sysManage.GetConfig("CompanyTel");
        txtTel.Text = telQuery.ConfigValue;

        SystemConfigQuery phoneQuery = sysManage.GetConfig("CompanyPhone");
        txtPhone.Text = phoneQuery.ConfigValue;

        SystemConfigQuery faxQuery = sysManage.GetConfig("CompanyFax");
        txtFax.Text = faxQuery.ConfigValue;   
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            SystemConfigQuery linkManconfig = sysManage.GetConfig("CompanyLinkMan");
            linkManconfig.ConfigValue = txtCNName.Text.Trim();

            SystemConfigQuery telQuery = sysManage.GetConfig("CompanyTel");
            telQuery.ConfigValue = txtTel.Text.Trim();

            SystemConfigQuery phoneQuery = sysManage.GetConfig("CompanyPhone");
            phoneQuery.ConfigValue = txtPhone.Text.Trim();

            SystemConfigQuery faxQuery = sysManage.GetConfig("CompanyFax");
            faxQuery.ConfigValue = txtFax.Text.Trim();

            sysManage.UpdateConfig(linkManconfig);
            sysManage.UpdateConfig(telQuery);
            sysManage.UpdateConfig(phoneQuery);
            sysManage.UpdateConfig(faxQuery);
            Jscript.Alert(Resources.Messages.UpdateSuccess, this.Page);
        }
        catch
        {
            Jscript.Alert(Resources.Messages.UpdateFailed, this.Page);
        }



    }
    protected void btnReset_Click(object sender, EventArgs e)
    {

    }
}
